package br.com.news.service;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import br.com.news.utils.business.exception.BusinessException;
import br.com.news.utils.business.interfaces.IContatoBusiness;
import br.com.news.utils.database.beans.ContatoBean;
import br.com.news.utils.service.exception.ServiceException;
import br.com.news.utils.service.interfaces.IContatoService;

@Named
public class ContatoService implements IContatoService{
	
	@Inject
	private IContatoBusiness contatoBusiness;

	@Override
	public List<ContatoBean> findAll() throws ServiceException{
		try {
			return contatoBusiness.findAll();
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}
	
	@Override
	public void save(ContatoBean contato) throws ServiceException {
		try {
			contatoBusiness.save(contato);
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}
	
	@Override
	public void update(ContatoBean contato) throws ServiceException {
		try {
			contatoBusiness.update(contato);
		} catch (BusinessException e) {
			throw new ServiceException("Erro ao tentar dar update o contato na camada do service.",e);
		}
	}
	
	@Override
	public List<ContatoBean> buscaContatosNaoEnviados() {
		return contatoBusiness.buscaContatosNaoEnviados();
	}
	
	

}
